/**
 * [orderFilterParam description]
 * @type {Object}
 */
var orderFilterParam = {
    inited: false,
    cache: {},
    singleShop: false,//是否是单门店
    params:{
        payType: '', //支付方式
        orderStatus: '',//订单状态
        orderSource:'',//订单来源
        shopId: '',//门店Id
        shopName: ''
    },    
    selectedOption:'1', //缓存选择的tab标签, 1:订单明细, 2:异常订单
    accountRole:"",//登录账户的角色
};
(function(doc, win) {

    // sui 页面就绪时间
    $(doc).on("pageInit", "#orderFilterPage", function(e, pageId, $page, isBack) {
        if (isBack) {
            //选择的门店信息
            orderFilterParam.params.shopId = storeListSelectOneFilterParam.shopId;  
            orderFilterParam.params.shopName = storeListSelectOneFilterParam.shopName;  
            if(orderFilterParam.params.shopId != '') {
                $('#orderFilterPage .page-body .store-name').html(orderFilterParam.params.shopName);    
            } else {
                $('#orderFilterPage .page-body .store-name').html("全部门店"); 
            }
                
        } else {
            var controller = new OrderFilterController();
            controller.getSessionUser({});                
        }        
    });


    // 选择
    $(doc).on('click','#orderFilterPage .filter-item',function(){
        debugger
        $(this).addClass("selected").siblings().removeClass("selected");
        var orderStatus = $(this).attr("status");

        if (orderStatus) {
            orderFilterParam.params.orderStatus = parseInt(orderStatus);
        } 
        var payType = $(this).attr("type");
        if(payType){
            orderFilterParam.params.payType = parseInt(payType);
        }
        var orderSource = $(this).attr("source");
        if(orderSource){
            orderFilterParam.params.orderSource = parseInt(orderSource);
        }
      
    });
   
    // 重置
    $(doc).on('click','#orderFilterPage .header .right a',function(){
        $('#orderFilterPage .filter-item').removeClass("selected");
        if(orderFilterParam.accountRole=="1"){
            $('#orderFilterPage .filter-item-store .store-name').html("全部门店");
        }
        orderFilterParam.params.payType = '';
        orderFilterParam.params.orderStatus = '';
        orderFilterParam.params.shopId = '';
        orderFilterParam.params.shopName = '';
        orderFilterParam.params.orderSource = '';
    });

    // 选择门店
    $(doc).on('click','#orderFilterPage .page-body .filter-list-content .filter-item-store',function(){
        $.router.load("store_list_select_one.html");
    });

    // 点击返回，清空选项
    $(doc).on('click','#orderFilterPage .scroll-view .header .left',function(){
        $('#orderFilterPage .page-body').empty();
    });
})(document, window);

